<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>后台管理</title>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/layui/css/layui.css" />
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/admin.css" />
<style>
.layui-form-label{ width:120px;}
.layui-form-checkbox{ height:20px; padding-right:20px;}
.layui-form-checkbox i{ width:20px; font-size: 12px; line-height:20px;}
.layui-input-block{ margin-left:160px;}
.layui-form-item .layui-form-checkbox{ margin-top:0px;}
.rule_item{ display:block; float:left; margin-right:15px; margin-bottom:10px;}
</style>
</head>
<body>
<div class="wrap-container">
  <form class="layui-form edit-form" method="post" action="{:url()}" style="width: 90%;padding-top: 20px;">
    {present name="info.id"}
    <input type="hidden" name="id" value="{$info.id|default=''}" />
    {/present}
    
    <div class="layui-form-item">
      <label class="layui-form-label">用户组：</label>
      <div class="layui-input-block">
        <input type="text" name="title" value="{$info.title|default=''}" required lay-verify="required" placeholder="请输入用户组" autocomplete="off" class="layui-input">
      </div>
    </div>
    
    
    {volist name='mgroup' id='mg'}
    <div class="layui-form-item" style=" margin-left:20px;border-bottom:#CCC solid 1px; padding-bottom:10px;">
    <h4><label>{$mg.title}权限分配：</label></h4>
    </div>
    
    {volist name='menulist[$mg["id"]]' id='vo'}
    {if condition="$vo['pid'] eq 0"}
    <div class="layui-form-item">
      <label class="layui-form-label"><input type="checkbox" name="rules[]" value="{$vo.rule_id}" lay-filter="rules" class="topm" />{$vo.title}：</label>
      <div class="layui-input-block">
        {volist name='menulist[$mg["id"]]' id='subvo'}
           {if condition="$subvo['pid'] eq $vo['id'] && $subvo['is_ts'] eq 0"}
              <label class="rule_item"><input type="checkbox" name="rules[]" value="{$subvo.rule_id}" lay-filter="rules" class="subm" /> {$subvo.title}</label>
           {/if}
        {/volist}
      </div>
    </div>
    {/if}
    {/volist}
    {/volist}
    

    

    
    
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn layui-btn-normal ajax-post-btn" lay-submit lay-filter="formDemo">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>
  </form>
</div>
<script src="__STATIC__/js/jquery.min.js" type="text/javascript" charset="utf-8"></script> 
<script src="__STATIC__/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="__STATIC__/js/common.js" type="text/javascript" charset="utf-8"></script> 
<script>
			//Demo
			layui.use(['form'], function() {
				var form = layui.form();
				form.render();
				//监听提交
				form.on('submit(formDemo)', function(data) {
					//layer.msg(JSON.stringify(data.field));
					ajax_post('edit-form',true,'iframe13','');
					return false;
				});
				
				
				form.on('checkbox(rules)', function(data){
				  	if(data.elem.checked == false){
						$(this).prop('checked',true);
					}else{
						$(this).prop('checked',false);	
					}
				  
				  //console.log(data.elem.checked); //是否被选中，true或者false
				  //console.log(data.value); //复选框value值，也可以通过data.elem.value得到
				  //console.log(data.othis); //得到美化后的DOM对象
				}); 
			});

		
{present name="info.id"}
$(function(){
	setValue('rules[]',[{$info.rules}]);
});
{/present}
</script>


</body>
</html>